Page({
  

  data: {
    thour:0.5,
    tid:33,
    tday:0.1, 
    empid:''

  },
  onLoad(query) {

   console.log(query);
   this.setData({
    thour:query.hour,
    tid:query.id,
    tday:(query.hour)/8,

  


   });

  dd.getStorage({
  key: 'staffid',
  success: function(res) 
  {
     this.setData({
       empid:res.data,

     });
  },



   })


  },

  info:function(e)
  {

  
  console.log(e);
  var dtime =e.detail.value.dtime;
  var begin =e.detail.value.begin;
  var end=e.detail.value.end;
  var hour=e.detail.value.hour;
  var day=e.detail.value.day;
  var remark=e.detail.value.remark;


   if(dtime==null||isNaN(dtime)||dtime.length!=8)
   {
      dd.showToast({
     
       content:'请填入正确的调休日期',
      });
      
   } else  if(begin==null||isNaN(begin)||begin.length!=4)
   {
      dd.showToast({
     
       content:'请填入正确的调休开始时间',
      });
      
   }else  if(end==null||isNaN(end)||end.length!=4)
   {
      dd.showToast({
     
       content:'请填入正确的调休结束时间',
      });
      
   }else{
  
     var that=this;

      dd.httpRequest({

        
          //提交工号和授权码，如果授权码和工号对上了就返回姓名，然后保存工号到缓存
          //url: 'https://oapi.dingtalk.com/user/getuserinfo?access_token=' + access_token + '&code=' + code,
        
          url:'http://ding.tida-lighting.com/api/Leave/apply',
           method: 'POST',
    data: {
           begin: dtime+begin,
           end: dtime+ end,
           hour:hour,
           day:day,
           year:'',
           typ:'调休假',
           empid:that.data.empid,
           reason:remark,
           idd:that.data.tid,
        },
        dataType: 'json',
          success: function (res) {
         
    
        dd.showToast({

        content:res.data,

        });

          
         },
        fail: (err) => {
           //dd.alert({content: JSON.stringify(err)})
           console.log(err);
        }

     });//发起结束



   }


  }
});
